$(function () {
    findAll();
});

function findAll() {
    let result = myAjax("/build", {}, "get");
    setDataCompany(result.companyModel);
    setConsultingData(result.consultingModelList);
    setOnlineData(result.onlineModelList);
    setNavWebsiteData(result.navModelList);
    setNavFirstData(result.navModelList);
    setProductListData(result.productModelList);
    console.log(result);
}

function setDataCompany(data) {
    $("#logo").attr('src' ,URI+'/propertyimg'+data.logo);
    $("#companyName").html(data.name);
    $("#qrCodeIndex").attr("src", URI + '/propertyimg'+ data.qrCodeIndex);
    $("#qrCodeIndexTitle").html(data.qrCodeIndexTitle);
    $("#qrCodeWeiXin").attr("src", URI + '/propertyimg'+ data.qrCodeWeiXin);
    $("#qrCodeWeiXinTitle").html(data.qrCodeWeiXinTitle);
    $("#recordMessage").html(data.recordMessage);
    $("#recordNumber").html(data.recordNumber);
}

/**
 *
 */
function setConsultingData(data) {
    let html = "";
    for (let i = 0; i < data.length; i++) {
        html += "<div>" + data[i].content + "</div>";
    }
    $("#consulting").html(html);
}

/**
 * 第三方网站导航
 */
function setNavWebsiteData(data) {
    let html = "";
    for (let i = 0; i < data.length; i++) {
        if (data[i].typeName === "第三方网站导航") {
            html += "<div><img src=" + URI + '/propertyimg'+ data[i].img + "></div>";
        }
    }
    $("#websiteNav").html(html);
}

/**
 * Online
 */
function setOnlineData(data) {
    let html = "";
    for (let i = 0; i < data.length; i++) {
        html += "<div>" + data[i].content + "</div>";
    }
    $("#online").html(html);
}

/***
 * 一级导航
 * @param data
 */
function setNavFirstData(data) {
    let html = "";
    for (let i = 0; i < data.length; i++) {
        if (data[i].typeName === "一级导航") {
            html += "<a href=" + URI + data[i].href + "><div>" + data[i].name + "</div></a>";
        }
    }
    $("#firsNav").html(html);

}

/**
 * 楼盘信息
 */
function setProductListData(data) {
    let html = "";
    for (let i = 0; i < 6; i++) {
        html += "<div>\n" +
            "            <div onclick='toDetailsPage("+data[i].id+")'><img src=" + URI+'/propertyimg'+data[i].img + "></div>\n" +
            "            <div><a href=" + data[i].id + ".html" + ">"+data[i].name+"</a></div>\n" +
            "            <div>\n" +
            "                <div>"+data[i].description+"</div>\n" +
            "            </div>\n" +
            "        </div>";
    }
    $("#buildList").html(html)
}
function toDetailsPage(id) {
    sessionStorage.setItem("buildId", id);
    window.open("/step-seven-xadmin/index/detailsPage/build/buildPage.html","_self");
}